#!/bin/bash

#  this script enable user select display mode.
#  created by root@RainStudio

export XF86CONFIG
oldxCfg=$XF86CONFIG

xcfgPath=/etc/X11
xcfgFile=XF86Config-4
xcfg640=XF86Cfg640-4
chrAns=""

if [ $# -gt 0 ]; then
  if [ $1 == "640" ]; then
    if [ -e $xcfgPath/$xcfg640 ]; then
      XF86CONFIG=$xcfg640
    else
      echo 
      echo "error: can't find config file '$xcfg640' in $xcfgPath."
      echo
      echo "hint:"
      echo "  1. how to create file '$xcfg640'?"
      echo "   . login as root"
      echo "   . modify a copy of X config file and rename '$xcfg640'"
      echo "   . place this file in $xcfgPath"
      echo
      echo -n "continue load x?"
      read chrAns
      if [ -n $chrAns ] && [ $chrAns != "y" ] && [ $chrAns != "Y" ]; then
        exit 0
      fi 
    fi
  fi
fi
xinit

XF86CONFIG=$oldxCfg
